Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for changing options dynamically. #33

Merged
merged 1 commit into from
Jun 22, 2013
Merged

Add support for changing options dynamically. #33

merged 1 commit into from
Jun 22, 2013

Conversation

killpack
Copy link
Contributor

Motivation: to make this plugin more usable for pages that use responsive
Bootstrap styling. On such pages, it is common for high-resolution views
to use a floating "sticky" nav bar (in which case StickyTableHeaders
needs an offset that's >= 0), while lower-resolution views might make
the nav bar "non-sticky" to conserve screen space. When the viewport
changes, it is necessary to tell StickyTableHeaders to change the
fixedOffset option so that it can account for the varying "stickiness"
of the nav bar. Prior to this commit, the only way to accomplish this
was to destroy the StickyTableHeaders instance and recreate it. I think
this fix is much easier and more efficient!

Motivation: to make this plugin more usable for pages that use responsive
Bootstrap styling. On such pages, it is common for high-resolution views
to use a floating "sticky" nav bar (in which case StickyTableHeaders
needs an offset that's >= 0), while lower-resolution views might make
the nav bar "non-sticky" to conserve screen space. When the viewport
changes, it is necessary to tell StickyTableHeaders to change the
fixedOffset option so that it can account for the varying "stickiness"
of the nav bar. Prior to this commit, the only way to accomplish this
was to destroy the StickyTableHeaders instance and recreate it. I think
this fix is much easier and more efficient!
@jmosbech jmosbech merged commit 548f70d into jmosbech:master Jun 22, 2013
@jmosbech
Copy link
Owner

Merged. Thanks for contributing and sorry for the long response time.

Cheers
J

@mmjain
Copy link

mmjain commented May 6, 2015

I have some issue in Stickyheader... My query is this work on window. but in my project work on div so how will solve. please Help for this.

@tonyfarr
Copy link

Hi,
I'm using stickyTableHeaders with FooTable. I'm having some difficulty with this fix for changing options dynamically. I'm sure it's just my understanding. However, would you show what the plugin call should look like please. I'm trying to use the code as shown in the read-me text:
$('table').stickyTableHeaders({fixedOffset: [new-offset]});

This only seems to work if I use the 'destroy' option. Which defeats the purpose.
In the initialising call, I am using a fixed-offset to allow for the top nav bar (and this works as expected).

var offset = $('.navbar').height();
$('#myDataTable').stickyTableHeaders({ fixedOffset: offset });

So I've set up window.addEventListener to listen for 'resize'. Then I call a function that changes the stickyTableHeaders. I seem to need to do the 'destroy' then run the same 2 lines of code to get height and call stickyTableHeaders.

As I said, this works with the destroy, but I'd like to know what I need to do to implement this fix (so that I don't have to use the destroy and recreate it - as described by kill pack above).

Sorry for the length of this. But I thought it best to explain in detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants